package jumpingnotes.model.entity;

import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import net.jf.lucene.analysis.mmseg.MMSegAnalyzer;

import org.hibernate.search.annotations.Analyzer;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.Store;

@Entity
@Table(name = "message", catalog = "jumping_notes")
@Indexed
@Analyzer(impl = MMSegAnalyzer.class)
public class Message implements java.io.Serializable
{

	private Integer messageId;
	private Member memberByMemberIdTo;
	private Member memberByMemberIdFrom;
	private Date createTime;
	private String body;
	private String subject;
	private Integer isRead;
	private Integer isDeletedTo;
	private Integer isDeletedFrom;
	private Integer type;

	public Message()
	{
	}

	public Message(Member memberByMemberIdTo, Member memberByMemberIdFrom, Date createTime, String body, String subject)
	{
		this.memberByMemberIdTo = memberByMemberIdTo;
		this.memberByMemberIdFrom = memberByMemberIdFrom;
		this.createTime = createTime;
		this.body = body;
		this.subject = subject;
	}

	public Message(Member memberByMemberIdTo, Member memberByMemberIdFrom, Date createTime, String body,
			String subject, Integer isRead, Integer isDeletedTo, Integer isDeletedFrom)
	{
		this.memberByMemberIdTo = memberByMemberIdTo;
		this.memberByMemberIdFrom = memberByMemberIdFrom;
		this.createTime = createTime;
		this.body = body;
		this.subject = subject;
		this.isRead = isRead;
		this.isDeletedTo = isDeletedTo;
		this.isDeletedFrom = isDeletedFrom;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "message_id", unique = true, nullable = false)
	@DocumentId
	public Integer getMessageId()
	{
		return this.messageId;
	}

	public void setMessageId(Integer messageId)
	{
		this.messageId = messageId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "member_id_to", nullable = false)
	public Member getMemberByMemberIdTo()
	{
		return this.memberByMemberIdTo;
	}

	public void setMemberByMemberIdTo(Member memberByMemberIdTo)
	{
		this.memberByMemberIdTo = memberByMemberIdTo;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "member_id_from", nullable = false)
	public Member getMemberByMemberIdFrom()
	{
		return this.memberByMemberIdFrom;
	}

	public void setMemberByMemberIdFrom(Member memberByMemberIdFrom)
	{
		this.memberByMemberIdFrom = memberByMemberIdFrom;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "create_time", nullable = false, length = 19)
	public Date getCreateTime()
	{
		return this.createTime;
	}

	public void setCreateTime(Date createTime)
	{
		this.createTime = createTime;
	}

	@Column(name = "body", nullable = false, length = 65535)
	@Field(index = Index.TOKENIZED, store = Store.NO)
	public String getBody()
	{
		return this.body;
	}

	public void setBody(String body)
	{
		this.body = body;
	}

	@Column(name = "subject", nullable = false)
	@Field(index = Index.TOKENIZED, store = Store.NO)
	public String getSubject()
	{
		return this.subject;
	}

	public void setSubject(String subject)
	{
		this.subject = subject;
	}

	@Column(name = "is_read")
	public Integer getIsRead()
	{
		return this.isRead;
	}

	public void setIsRead(Integer isRead)
	{
		this.isRead = isRead;
	}

	@Column(name = "is_deleted_to")
	public Integer getIsDeletedTo()
	{
		return this.isDeletedTo;
	}

	public void setIsDeletedTo(Integer isDeletedTo)
	{
		this.isDeletedTo = isDeletedTo;
	}

	@Column(name = "is_deleted_from")
	public Integer getIsDeletedFrom()
	{
		return this.isDeletedFrom;
	}

	public void setIsDeletedFrom(Integer isDeletedFrom)
	{
		this.isDeletedFrom = isDeletedFrom;
	}

	@Column(name = "type")
	public Integer getType()
	{
		return this.type;
	}

	public void setType(Integer type)
	{
		this.type = type;
	}

}
